package com.ytjj.bigdata.service;

import com.github.pagehelper.PageHelper;
import com.ytjj.bigdata.dao.AdsAppOperateMapper;
import com.ytjj.bigdata.entity.AdsAppOperate;
import com.ytjj.bigdata.model.dto.AdsAppOperateDto;
import com.ytjj.common.api.CommonPageExtend;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class AdsAppOperateService {

    @Resource
    private AdsAppOperateMapper adsAppOperateMapper;

    public CommonPageExtend selectAdsAppOperate(AdsAppOperateDto adsAppOperateDto) {
        PageHelper.startPage(adsAppOperateDto.getPageNum(),adsAppOperateDto.getPageSize());
        List<AdsAppOperate> list = adsAppOperateMapper.selectAdsAppOperateAll(adsAppOperateDto);

        if (CollectionUtils.isEmpty(list)) {
            return new CommonPageExtend();
        }

        CommonPageExtend<AdsAppOperate> pageExtend = CommonPageExtend.restPage(list);

        return pageExtend;
    }
}
